package top.lihope.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.lihope.bean.Student;
import top.lihope.respond.R;
import top.lihope.service.StudentService;

/**
 * @description:
 * @ClassName: StudentApi
 * @author: 求求别学了，我跟不上
 * @email: xiwang.li@qq.com
 * @date： 2023/4/12 10:12
 * @version： 1.0
 */
@RestController
@RequestMapping("/student")
public class StudentApi {

    @Autowired
    private StudentService studentService;

    @GetMapping("/list")
    public R getStudentList(){
        return R.success().setData(studentService.selectAll());
    }

    @GetMapping("/insert")
    public R insert(){
        Student student = new Student(1, "测试","测试地址");
        return R.success().setData(studentService.insertStudent(student));
    }

    @GetMapping("/delete/{id}")
    public R deleteById(@PathVariable Integer id){
        return R.success().setData(studentService.deleteById(id));
    }
}
